package com.yehongyu.mytools.ui.app;


import java.awt.Color;
import java.awt.Font;
import java.io.FileInputStream;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JPanel;

import org.jdom.Element;

import com.yehongyu.mytools.ui.swing.Show;

public class ListThree extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = -5589131547113879340L;
	JComboBox combo = new JComboBox();
	public ListThree() {
		try {
//			setLayout(new GridLayout(1, 1));

			combo.setBackground(Color.WHITE);
			combo.setForeground(Color.BLUE);
			combo.setFont(new Font(null, 0, 13));
			combo.setEditable(true);
			
			org.jdom.input.SAXBuilder sb = new org.jdom.input.SAXBuilder();
			// 创建文档
			org.jdom.Document doc = sb.build(new FileInputStream(
					"d:\\assettypedata.xml"));
			// 获得这个文档得跟元素
			org.jdom.Element el = doc.getRootElement();
			// 获得这个跟元素，的所有子元素
			List<?> ls = el.getChildren();

			for (int i = 0; i < ls.size(); i++) {
				org.jdom.Element e1 = (Element) ls.get(i);
				Element e2name = (Element)e1.getChildren().get(0);
				org.jdom.Element e2value = e1.getChild(e2name.getName());
//				System.out.println(e2name.getName());
				combo.addItem(e2value.getValue().trim());
			}
			add(combo);
		} catch (Exception e) {
			System.out.println(e.getMessage());

		}
	}
	public String getValue(){
		return (String)combo.getSelectedItem();
	}
	public static void main(String args[]) {
		Show.inFrame(new ListOne(), 200, 200);
	}
} // /:~